ARG BASE_IMAGE=ohos_deps

FROM $BASE_IMAGE AS ohos_user
ARG UID=1000
ARG GID=$UID
ARG USER=ohos
ARG GROUP=$USER

RUN apt-get update && apt-get install -y \
    sudo \
    && rm -rf /var/lib/apt/lists/*

RUN groupadd --gid $GID $GROUP \
        && adduser --uid $UID --gid $GID --shell /bin/bash $USER \
        && adduser $USER sudo \
        && echo $USER ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USER \
        && chmod 0440 /etc/sudoers.d/$USER

USER $USER

RUN touch ~/.sudo_as_admin_successful


FROM ohos_user AS ohos_ohpb
ARG WS_DIR=/workspace
ARG WS_NAME=ohos

# RUN sudo mkdir -p $WS_DIR/openharmony_prebuilts
RUN sudo mkdir -p $WS_DIR/${WS_NAME}

WORKDIR ${WS_DIR}
